<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="180px"
    >


      <el-form-item label="永昌合同编号" prop="ycNumber">
        <el-input
          v-model="queryParams.ycNumber"
          placeholder="永昌合同编号"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="九州合同编号" prop="jzNumber">
        <el-input
          v-model="queryParams.jzNumber"
          placeholder="九州合同编号"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="tableData">
      <el-table-column label="电子合同编号" align="center" prop="contractNumber"/>
      <el-table-column label="九州合同编号" align="center" prop="jzNumber"/>
      <el-table-column show-overflow-tooltip width="250" label="签署链接" align="center" prop="signingUrl">
        <template slot-scope="scope">
          <span style="color: #00afff" @click="handleClick(scope.row.signingUrl)">
            {{ scope.row != null ? scope.row.signingUrl : '' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip width="300" label="合同地址" align="center" prop="viewUrl">
        <template slot-scope="scope">
          <span style="color: #00afff" @click="handleClick(scope.row.viewUrl)">
            {{ scope.row != null ? scope.row.viewUrl : '' }}
          </span>
        </template>
      </el-table-column>
      <el-table-column width="200" label="出发时间" align="center" prop="contractDto.saleOrderDto.leaveDt"/>
      <el-table-column width="200" label="线路名称" align="center" prop="contractDto.saleOrderDto.productName"/>
      <el-table-column width="200" label="生成时间" align="center" prop="addDate"/>
      <el-table-column label="状态" align="center" prop="stateText"/>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="160">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="handleDetail(scope.row)"
          >详情
          </el-button>
          <el-button
            size="mini"
            type="text"
            v-if="scope.row.state==1"
            icon="el-icon-document"
            @click="econtractResend(scope.row)"
          >重发短信
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <Detail ref="detailDialog"/>
  </div>
</template>

<script>
import {pageList} from "@/api/salepurchase/electroncon"
import {econtractResend} from "@/api/tool/tourism"

export default {
  name: "yccontract",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      tableData: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ycNumber: "",
        jzNumber: "",
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询合同列表 */
    getList() {
      this.loading = true
      pageList(this.queryParams).then(response => {
          this.tableData = response.rows
          this.total = response.total
          this.loading = false
        }
      )
    },
    econtractResend(data) {
      const info={
        contractNumber:data.contractNumber,
        phone: ''
      }
      this.$modal.confirm('确认发送').then(function () {
        return econtractResend(info);
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("发送成功")
      }).catch(() => {
      })

    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    handleClick(hrefUrl) {
      window.open(hrefUrl, '_blank');
    },

    /** 查看详情操作 */
    handleDetail(row) {
      this.$refs.detailDialog.open(row.id)
    },

  }
}
</script>
